package org.example.service.impl;

import org.example.dao.ICategoryDao;
import org.example.entity.CategoryEntity;
import org.example.exception.UserException;
import org.example.service.ICategoryService;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.List;

/**
 * @author HanJiafeng
 */
@Service
public class CategoryServiceImpl implements ICategoryService {
    private final ICategoryDao categoryDao;

    public CategoryServiceImpl(ICategoryDao categoryDao) {
        this.categoryDao = categoryDao;
    }

    @Override
    public List<CategoryEntity> list() throws UserException {
        try {
            return categoryDao.selectSelective(new CategoryEntity());
        } catch (IOException e) {
            throw new UserException("初始化产品类别异常", e);
        }
    }
}
